
export const antishake = (app: any) => {
    app.directive("antisana", {
        mounted(el: any, binding: any) {
            let throttleTime = binding.value
            if (!throttleTime) {
                throttleTime = 1000
            }
            el.addEventListener('click', () => {
                if (!el.disabled) {
                    el.disabled = true;
                    setTimeout(() => {
                        console.log(1);
                        el.disabled = false;
                    }, throttleTime)
                }
            })
        },
        updated(el: any, binding: any) {
            let throttleTime = binding.value
            if (!throttleTime) {
                throttleTime = 1000
            }
            el.addEventListener('click', () => {
                if (!el.disabled) {
                    el.disabled = true;
                    setTimeout(() => {
                        console.log(2);
                        el.disabled = false;
                    }, throttleTime)
                }
            })
        }
    })
}

